const path = require("path");
// const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
// const AutoDllPlugin = require("autodll-webpack-plugin");

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  devServer: {
    disableHostCheck: true,
    proxy: {
      "/api/": {
        //匹配所有以/api/为开头的接口
        target: "https://muguakjyxgs.com:3443",
        //后端服务器地址
        changeOrigin: true,
        pathRewrite: {
          "/api/": "/api/"
        }
      }
    }
  },
  assetsDir: "h5",
  lintOnSave: false,
  configureWebpack: config => {
    Object.assign(config.resolve.alias, {
      "@utils": resolve("src/utils"),
      "@libs": resolve("src/libs"),
      "@api": resolve("src/api"),
      "@components": resolve("src/components"),
      "@assets": resolve("src/assets"),
      "@css": resolve("src/assets/css"),
      "@images": resolve("src/assets/images"),
      "@views": resolve("src/views"),
      "@mixins": resolve("src/mixins")
    });

    if (process.env.NODE_ENV !== "production") {
      config.plugins.push(
        // new HardSourceWebpackPlugin(),
        // new AutoDllPlugin({
        //   inject: true,
        //   debug: true,
        //   filename: "[name]_[hash].js",
        //   path: "./dll" + Date.parse(new Date()),
        //   entry: {
        //     vendor_vue: ["vue", "vuex", "vue-router"],
        //     vendor_ui: ["vue-awesome-swiper", "vue-ydui"],
        //     vendor_tools: ["axios", "core-js"]
        //   }
        // })
      );
    }
  },
  chainWebpack: config => {
    // config.plugin("html").tap(args => {
    //   args[0].VUE_APP_NAME = process.env.VUE_APP_NAME;
    //   return args;
    // });
  }
};
